package cn.cnxfs.demo.spring_jsp_demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class LoginController {
    private final static Logger logger = LoggerFactory.getLogger(LoginController.class);

    @RequestMapping("/hello")
    public String hello(){
        logger.info("进入/hello");
        return "index"; //展示index.jsp的内容
    }

    @RequestMapping("/mod")
    @ResponseBody
    public ModelAndView mod(){
        logger.info("进入/mod");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("mod");
        modelAndView.addObject("message", "123456"); //传参数到jsp页面
        return modelAndView; //渲染并展示mod.jsp的内容
    }

    @RequestMapping("login")
    @ResponseBody
    public String login(){
        logger.info("进入/login");
        return "login"; //直接返回字符串
    }
}
